#include "DarkTitleDialog.h"
#include "DarkTitleBar.h"
#include <QVBoxLayout>

DarkTitleDialog::DarkTitleDialog(QWidget* p )
    :QDialog(p)
{
    setWindowFlags(Qt::FramelessWindowHint);
   
    pTitleBar = new DarkTitleBar(this);
    installEventFilter(pTitleBar);
    setWindowTitle(QString::fromLocal8Bit(""));

    QVBoxLayout*  verticalLayout = new QVBoxLayout();
    verticalLayout = new QVBoxLayout(this);
    verticalLayout->setSpacing(1);
    verticalLayout->setContentsMargins(1, 1, 1, 1);
    verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
    //verticalLayout->setSizeConstraint(QLayout::SetFixedSize);
    verticalLayout->setContentsMargins(1, 1, 1, 1);
    //verticalLayout->addWidget(pTitleBar);

    QHBoxLayout* titleLayout = new QHBoxLayout();
    titleLayout->setSpacing(0);
    titleLayout->setObjectName(QStringLiteral("titleLayout"));
    titleLayout->setSizeConstraint(QLayout::SetDefaultConstraint);
    titleLayout->setContentsMargins(0, 0, 0, 0);
    titleLayout->addWidget(pTitleBar);

    verticalLayout->addLayout(titleLayout);

    contentLayeout = new QVBoxLayout();
    contentLayeout->setSpacing(0);
    contentLayeout->setObjectName(QStringLiteral("contentLayeout"));
    contentLayeout->setSizeConstraint(QLayout::SetDefaultConstraint);
    contentLayeout->setContentsMargins(0, 0, 0, 0);

    verticalLayout->addLayout(contentLayeout);

    verticalLayout->setStretch(1, 10);
    this->setLayout(verticalLayout);
    layeout = verticalLayout;

}


DarkTitleDialog::~DarkTitleDialog()
{
}

void DarkTitleDialog::addWidgetContent(QWidget * w)
{
    int w1 = w->width();
    int h1 = w->height();
    this->resize(w1, h1+50);
    setWindowTitle(w->windowTitle());
    contentLayeout->addWidget(w);
    connect(w, SIGNAL(finished(int)), this, SLOT(done(int)));
}

void DarkTitleDialog::setMainWindowMode()
{
    pTitleBar->setMainWindowMode();
}
